package IOPeration;

import Book.Book;
import Book.BookList;

import java.util.Scanner;

public class Browbook implements Ioperation {
    public void work(BookList bookList){
        System.out.println("借出图书");
        System.out.println("请输入您要借阅的书名");
        Scanner scanner=new Scanner(System.in);
        String name= scanner.nextLine();
        int currenTsize= bookList.getUsedsize();
        for(int i=0;i<currenTsize;i++){
             Book book= bookList.getBooks(i);
             if(book.getName().equals(name)){
                 if(book.isIsborrow()){
                     System.out.println("这本书已经被借出了");
                     return;
                 }
                 book.setIsborrow(true);
                 System.out.println("借阅成功");
                 return;
             }
        }
        System.out.println("没有你要借阅的图书");
    }
}
